<script type="text/javascript" src="java/formval.js"></script>
<script type="text/javascript">
function validateOnSubmit(formElem) {
	var elem;
	var errs=0;
	if (!validatePresent(formElem.KategorieID,  'KategorieError', true))  		errs = 1;
	
	if (errs==0){
		formElem.submit();
	}
};
</script>
<?PHP
function GetKategorie(& $KategorieList, $selectID) {
	$sql = "select * FROM kategorie";
	global $_db_link;
	$_rd = mysql_query($sql, $_db_link);
	if ($_rd) {
		while ($daten = mysql_fetch_array($_rd, MYSQL_ASSOC)) {
			$datakategorie[] = $daten;
		}
	}
	if ($selectID == NULL || $selectID == 0) {
		$KategorieList = $KategorieList . '<option value="" selected="selected">Please Select</option>';
	} else {
		$KategorieList = $KategorieList . '<option value="">Please Select</option>';
	}
	$KategorieList = $KategorieList . getOption(& $datakategorie, $selectID);
	$KategorieList = $KategorieList . "</select>";
}


if (!empty($_SESSION["CMS_User"]["ID"]) && ($_POST["edit"]==1) && !empty ($_POST["setting"]) && !empty ($_POST["Titel"]) ) { //edit	
 
$sql = "update tagmodule set Setting='".$_POST["setting"]."' ,Titel='" . $_POST["Titel"] . "' ,Postion=" . $_POST["Postion"] . ",Border=" . $_POST["Border"] . ",TitelShow=" . $_POST["TitelShow"] . " WHERE ID=".$_POST["moduleid"]." and TagID=".$_POST["tagid"];
				
$_rd = mysql_query($sql, $_db_link);
}
else if (!empty($_SESSION["CMS_User"]["ID"]) && ($_POST["edit"]==1) && !empty ($_POST["Titel"]) ) { //edit	
 
$sql = "update tagmodule set Titel='" . $_POST["Titel"] . "' ,Postion=" . $_POST["Postion"] . ",Border=" . $_POST["Border"] . ",TitelShow=" . $_POST["TitelShow"] . " WHERE ID=".$_POST["moduleid"]." and TagID=".$_POST["tagid"];
				
$_rd = mysql_query($sql, $_db_link);
}

if ($_POST["edit"]==1)
{
GotoURL("index.php?tag=".$_POST['tagid']);
}

?>
<form method="POST" id="MaduleEditor" action="">
<div style="width:100%;background-color:#F1EEF3;margin:0px"> 

<table class="tableEdit">
     <?PHP
 
                if($R_MoudeTagID)
                {
	        $sql="select * FROM tagmodule WHERE ID=$R_MoudeTagID";
	        $_rd= mysql_query($sql,$_db_link);
	        if($_rd)
                   {
		   $daten=mysql_fetch_array($_rd,MYSQL_ASSOC);

                   $_Titel=$daten["Titel"];
                   $_Postion=$daten["Postion"];
                   $_ModuleID=$daten["ID"];
                   $_TagID=$daten["TagID"];
                   $_Border=$daten["Border"];
                   $_TitelShow=$daten["TitelShow"];
                   $_ModuleIDType=$daten["ModuleID"];
                   $_Setting=$daten["Setting"];
                   
                
                      if ($_ModuleIDType==3) {
                         $KategorieList = '<select name="setting" id="setting" onchange="validatePresent(this, \'KategorieError\');">';
	                 GetKategorie($KategorieList, $daten["Setting"]);
                                             }
                   } 
                }
                
                ?>
    
    <input type=text value='<?PHP echo $_ModuleID; ?>' style="display:none" name="moduleid">
    <input type=text value='<?PHP echo $_TagID; ?>' style="display:none" name="tagid">
    <input type=text value="1" style="display:none" name="edit">  
<tr>
        <td class="lableEdit"><?PHP  LangText("Titel");?>:</td>
        <td><input Type="text" name="Titel" value=<?PHP echo "'$_Titel'" ?> ></td>
    </tr> 
   <tr>  
    <td class="lableEdit"><?PHP  LangText("Postion");?>:</td>
        <td><select name="Postion">
            <option value="2" <?PHP if ($_Postion==2) echo "selected"; ?> >
            Center</option>
            <option value="0" <?PHP if ($_Postion==0) echo "selected"; ?> >
            Top</option>
            <option value="1" <?PHP if ($_Postion==1) echo "selected"; ?> >
            Left</option>
            <option value="3" <?PHP if ($_Postion==3) echo "selected"; ?> >
            Right</option>
            <option value="4" <?PHP if ($_Postion==4) echo "selected"; ?> >
            Down</option>
        </select></td>
    </tr>
    <tr>  
    <td class="lableEdit"><?PHP  LangText("Border");?>:</td>
        <td><select name="Border">
            <option value="0" <?PHP if ($_Border==0) echo "selected"; ?> >
            Ja - Border</option>
            <option value="1" <?PHP if ($_Border==1) echo "selected"; ?> >
            Nein - Border</option>
        </select></td>
    </tr>
    <td class="lableEdit"><?PHP  LangText("TitelShow");?>:</td>
        <td><select name="TitelShow">
            <option value="0" <?PHP if ($_TitelShow==0) echo "selected"; ?> >
            Ja - TitelShow</option>
            <option value="1" <?PHP if ($_TitelShow==1) echo "selected"; ?> >
            Nein - TitelShow</option>
        </select></td>
    </tr>
<?PHP
if ($_ModuleIDType==3)   
{
?>
    <tr>
		<td class="lableEdit"><?PHP  LangText("KategorieID");?>:</td>
		<td class="inputEdit"><?PHP echo $KategorieList; ?></td>
		<td class="validateEdit"><input type="label" DISABLED
			id="KategorieError" value='<?PHP LangText("KategorieError");?>' /></td>
    </tr>
<?PHP
}
else
{
?>
<input type=text value='<?PHP echo $_Setting; ?>' style="display:none" name="setting">
<?PHP
}
?>
    <tr>
        <td></td>
        <td><input type="submit" class="BootenLink"  name="butEdit"  value='<?php LangText("EditModule"); ?>'>
        </td>
    </tr>
</table>
</div>
</form>

    